--[[
  图的边
--]]

local info = debug.getinfo(1, "S") -- 第二个参数 "S" 表示仅返回 source,short_src等字段， 其他还可以 "n", "f", "I", "L"等 返回不同的字段信息
for k,v in pairs(info) do
    print(k, ":", v)
end
local path = info.source
path = string.sub(path, 2, -1) -- 去掉开头的"@"
path = string.match(path, "^.*\\") -- 捕获最后一个 "/" 之前的部分 就是我们最终要的目录部分
path = string.sub(path,1,#path-1)
path = string.match(path, "^.*\\")
print("dir=", path)
path = path .. "?.lua;"
package.path = path.. package.path 

-- print(package.path)
require("functions")

local GraphEdge = class("GraphEdge")

local invalid_node_index = -1

function GraphEdge:ctor(from,to,cost)
  print("_____GraphEdge____",from,to,cost)
  --1条边会连接2个节点
  self.m_iFrom = from or invalid_node_index
  self.m_iTo = to or invalid_node_index
  --花费
  self.m_dCost = cost or 1

end

function GraphEdge:print( ... )
  print("graphEdge->",self.m_iFrom,self.m_iTo,self.m_dCost)
end

function GraphEdge:setFrom(from)
  self.m_iFrom = from
end
function GraphEdge:getFrom( ... )
  return self.m_iFrom
end

function GraphEdge:setTo(to)
  self.m_iTo = to
end
function GraphEdge:getTo( ... )
  return self.m_iTo
end

function GraphEdge:setCost(cost)
  self.m_dCost = cost
end
function GraphEdge:getFrom( ... )
  return self.m_dCost
end

function GraphEdge:compare(edge)
  if self.m_iFrom == edge.m_iFrom and self.m_iTo == edge.m_iTo and self.m_dCost == edge.m_dCost then 
    return true
  end
  return false
end


return GraphEdge